package com.kaka.bus.engine.home.info.self;

import com.kaka.bus.bean.HttpWrapper;
import com.kaka.bus.bean.User;
import com.kaka.bus.di.DataManager;
import com.kaka.bus.manager.Result;
import com.kaka.bus.manager.T;
import com.kaka.bus.mvp.RxPresenter;
import com.kaka.bus.util.U;

import javax.inject.Inject;

/**
 * Created by zhangqi on 2016/10/31.
 */

public class SelfPresenter extends RxPresenter<SelfContract.View> implements SelfContract.Presenter{

    @Inject
    public SelfPresenter(DataManager dataManager) {
        super(dataManager);
    }

    @Override
    public void loadSelfInfo(String userId,String token) {
        addSubscribe(mDataManager
                .getApi()
                .getPersonInfo(userId,token, U.Sign(userId,token))
                .compose(T.D())
                .subscribeWith(new Result<HttpWrapper<User>>() {

                    @Override
                    protected void onSuccess(HttpWrapper<User> wrapper) {
                        mView.loadSuccess(wrapper);
                    }

                    @Override
                    protected void onFinish() {
                        super.onFinish();
                        mView.onFinish();
                    }

                }));
    }
}
